package com.yuantu.judiciary.controller;

import com.yuantu.judiciary.annotation.Log;
import com.yuantu.judiciary.common.Response;
import com.yuantu.judiciary.common.ResponseFactory;
import com.yuantu.judiciary.model.form.AddUserForm;
import com.yuantu.judiciary.model.form.ModifyUserForm;
import com.yuantu.judiciary.model.form.SearchEnterFrom;
import com.yuantu.judiciary.model.form.SearchEnterUserFrom;
import com.yuantu.judiciary.model.vo.*;
import com.yuantu.judiciary.service.IOrganizationService;
import com.yuantu.judiciary.service.IOrganizationSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import java.util.List;


/**
 * 组织管理模块
 *
 * @author syw
 * @since 2023-08-12
 **/
@RestController
@RequestMapping(value = "/org/source")
@Api(tags = "组织来源管理模块")
@RequiredArgsConstructor
public class OrganizationSourceController extends BaseController {

    private final IOrganizationSourceService organizationSourceService;

    @ApiOperation(value = "管理端-获取企业来源列表")
    @PostMapping("/list")
    public Response<PageVO<OrgSourceVO>> searchEnterPage(@PageableDefault(sort = "createTime", direction = Sort.Direction.DESC) Pageable pageable,
                                                          @RequestParam String orgSource) {
        return ResponseFactory.okResponse(organizationSourceService.searchOrgSourceInfos(orgSource, pageable));
    }


    @Log(title = "新增/修改企业来源")
    @ApiOperation(value = "管理端-新增/修改企业来源")
    @PostMapping("/update")
    public Response<Boolean> updateOrgSource(@RequestBody @Validated OrgSourceVO orgSource) {

        return ResponseFactory.okResponse(organizationSourceService.updateOrgSource(orgSource));
    }


    @Log(title = "删除企业来源")
    @ApiOperation(value = "删除企业来源")
    @GetMapping("/remove")
    public Response<Boolean> removeOrgSource(@RequestParam Long orgSourceId) {
        return ResponseFactory.okResponse(organizationSourceService.removeOrgSource(orgSourceId));
    }






}
